﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using System.IO;

namespace StoreM
{
    public partial class frmStoreM : RibbonForm
    {
        public frmStoreM()
        {
            InitializeComponent();
            InitSkinGallery();
            InitGrid();

        }
        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }
        BindingList<Person> gridDataList = new BindingList<Person>();
        void InitGrid()
        {
            gridDataList.Add(new Person("John", "Smith"));
            gridDataList.Add(new Person("Gabriel", "Smith"));
            gridDataList.Add(new Person("Ashley", "Smith", "some comment"));
            gridDataList.Add(new Person("Adrian", "Smith", "some comment"));
            gridDataList.Add(new Person("Gabriella", "Smith", "some comment"));
            
        }

        private void frmStoreM_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'storeDataSet.Staff' table. You can move, or remove it, as needed.
            this.staffTableAdapter.Fill(this.storeDataSet.Staff);
            #region (Load skin)
            // choose skin code 
            //SkinHelper.InitSkinPopupMenu(chooseSkin);
            // load last chosed skin            
            string fileName = Application.StartupPath + @"\Skin.txt";
            if (System.IO.File.Exists(fileName) == false)
            {
                defaultLookAndFeel1.LookAndFeel.SetSkinStyle("Blueprint");
            }
            else
            {
                StreamReader objRead = new StreamReader(fileName, false);
                defaultLookAndFeel1.LookAndFeel.SetSkinStyle(objRead.ReadLine());
                objRead.Dispose();
                objRead.Close();
            }
            #endregion


        }


        #region Save last skin
        private void frmStoreM_FormClosing(object sender, FormClosingEventArgs e)
        {
             // save last chosen skin
            string skin = defaultLookAndFeel1.LookAndFeel.SkinName;
            
            string  fileName = Application.StartupPath.ToString() + "\\Skin.txt";
            StreamWriter objWrite = new StreamWriter(fileName, false);
            objWrite.WriteLine(skin);
            objWrite.Dispose(); 
            objWrite.Close();        
        }
        #endregion

        private void ribbonControl_SelectedPageChanged(object sender, EventArgs e)
        {
            if (ribbonControl.SelectedPage.Equals(rpStaff))
            {
                frmStaff f = new frmStaff();
                //f.MdiParent = this;
                f.TopLevel = false;
                splitContainerCotrol.Panel2.Controls.Add(f);
                f.defaultLookAndFeel1.LookAndFeel.SetSkinStyle(this.defaultLookAndFeel1.LookAndFeel.SkinName);
                f.Show();
                
            }
        }
        }

    }
